/*
This file is part of luacalc
(C) 2006 Richard Simes
You may distribute it under the terms of the GNU General Public License
*/
#ifndef LUACALCGRID_H
#define LUACALCGRID_H


#ifdef __BORLANDC__
    #pragma hdrstop
#endif


#include <wx/wx.h>


#include <wx/grid.h>



#ifdef __cplusplus
extern "C" {
#endif

#include "lua.h"

#include "lauxlib.h"
#include "lualib.h"

#ifdef __cplusplus
}
#endif


/**
 * Custom grid class that stores and retrieves data
 * in the lua api.
 *
 *
 */

class LuaCalcGrid : public wxGridTableBase {
    public:
    LuaCalcGrid(wxGrid* g);
    int GetNumberRows();
    int GetNumberCols();
    bool IsEmptyCell(int row, int col);
    wxString GetValue(int row, int col);
    void SetValue(int row, int col, const wxString& value);
    wxString GetTypeName(int row, int col);

    //Data type determination and value access.
    bool CanGetValueAs(int row, int col, const wxString& typeName);
    bool CanSetValueAs(int row, int col, const wxString& typeName);
    long GetValueAsLong(int row, int col);
    double GetValueAsDouble(int row, int col);
    bool GetValueAsBool(int row, int col);
    void SetValueAsLong(int row, int col, long value);
    void SetValueAsDouble(int row, int col, double value);
    void SetValueAsBool(int row, int col, bool value);
    //For user defined types
    void* GetValueAsCustom(int row, int col, const wxString& typeName);
    void SetValueAsCustom(int row, int col, const wxString& typeName, void* value);

    lua_State* L;
    wxGrid* grid;
  

};



static int l_showMessage(lua_State*);

static int l_input(lua_State*);


#endif
